package com.lx.dao;

import com.lx.entity.Category;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface CategoryDao {
    List<Category> selectAll();
    List<Category> selectByPage(Map<String, Object> params);

    List<Category> selectByType(@Param("type")Integer type, @Param("id") Integer id);
//    int totalCount(Map<String, Object> params);
    Category selectById(Integer id);

    boolean insert(Category category);
    boolean update(Category category);
    boolean delete(Integer id);

    //查询相同type下是否存在相同的分类名
    int selectCountByName(@Param("name")String name, @Param("type")Integer type);

    // 查询是否有子分类或被商品引用
    int hasUsed(Integer id);
}
